package cn.infomany.util;

import org.beetl.core.Context;
import org.beetl.core.Function;

/**
 * 字符串工具,用于beetl
 *
 * @author zjb
 */
public class UncapFirst implements Function {

    public static String uncapFirst(String name) {
        String firstChar = name.substring(0, 1);
        String firstLowerCase = firstChar.toLowerCase();
        return firstLowerCase + name.substring(1);
    }

    @Override
    public Object call(Object[] objects, Context context) {
        if (objects == null || objects.length == 0) {
            return null;
        }
        Object object = objects[0];
        String name = object.toString();
        return uncapFirst(name);
    }
}
